<?php
/**
 * Created by PhpStorm.
 * User: t.young
 * Date: 2018/6/8
 * Time: 16:28
 */

namespace backend\modules\system\controllers;


use backend\component\BackendBaseController;
use backend\component\ResultFormat;
use backend\service\AreaService;
use common\models\base\Area;

class AreaController extends BackendBaseController
{
    public function actions()
    {
        return [
            "modify" => [
                'class' => "backend\actions\ModifyAction",
                'modelName'=> Area::className()
            ],
        ];
    }

    public function actionList($parent_id=0) {
        if (\Yii::$app->request->getIsAjax()) {
            $_POST['parent_id'] = $parent_id;
            return AreaService::areaDataList(\Yii::$app->request->post());
        }
        $model = new Area();
        return $this->render("list",['model'=>$model,'parent_id'=>$parent_id]);
    }


    public function actionEdit($id=0) {
        $model = Area::modelById($id);
        return $this->render("edit",['model'=>$model]);
    }

    public function actionDelete() {
        return ResultFormat::error("暂不支持删除");
    }
}